std::is_same

From Cppreference

Jump to: navigation, search
Defined in header <type_traits>

template< class T, class U >
struct is_same;
(C++11 feature)

If T and U name the same type with the same const-volatile qualifications, provides the member constant value equal to true. Otherwise value is false.

Contents

Inherited from std::true_type or std::false_type

Member objects

value true if T and U is the same type, false otherwise
(public member object)

[edit] Equivalent definition

[edit] Example

#include <type_traits>
 
int main()
{
    static_assert(std::is_same<int, int>::value, "int == int"); // passed
    typedef int foo;
    static_assert(std::is_same<int, foo>::value, "int == foo"); // passed
    static_assert(std::is_same<int, const int>::value, "int == const int"); // failed
}

[edit] See also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
In other languages